package edu.hawaii.duedates.configuration;

import java.io.Serializable;

/**
 * Holds each user's login data and library data specified in the XML configuration file.
 * 
 * @author tylerwolff
 */
public class User implements Serializable {

  /**
   * 
   */
  private static final long serialVersionUID = 1L;
  /** Holds the users login credentials. */
  private final String name;
  private final String email;
  private final String password;
  
  /** Holds the users library information, formatted for string arguments. */
  private String uhManoa = "";
  private String hawaiiStateLib = "";
  
  /**
   * Constructs the default user object based on login credentials.
   * 
   * @param name The name of the user.
   * @param email The email of the user.
   * @param password The password needed for login
   */
  public User (String name, String email, String password) {
    this.name = name;
    this.email = email;
    this.password = password;
  }

  /**
   * Sets the UH Library information.
   * 
   * @param uhManoa the uhManoa String to set.
   */
  public void setUhManoa(String uhManoa) {
    this.uhManoa = uhManoa;
  }

  /**
   * Sets the Hawaii State Library information.
   * 
   * @param hawaiiStateLib the hawaiiStateLib to set.
   */
  public void setHawaiiStateLib(String hawaiiStateLib) {
    this.hawaiiStateLib = hawaiiStateLib;
  }

  /**
   * Returns the name of user.
   * @return the name of user.
   */
  public String getName() {
    return this.name;
  }

  /**
   * Returns the email of user.
   * @return the email of user.
   */
  public String getEmail() {
    return this.email;
  }
  
  /**
   * Returns the password of user.
   * @return the password of user.
   */
  public String getPassword() {
    return this.password;
  }

  /**
   * Returns the data from the uhManoa and HawaiiStateLib String
   * fields and puts them together to return.
   * @return A string of library arguments.
   */
  public String getLibraryArgs () {
    
    if (("").equals(this.uhManoa) && !("").equals(this.hawaiiStateLib)) {
      return this.hawaiiStateLib;
    }
    else if (!("").equals(this.uhManoa) && ("").equals(this.hawaiiStateLib)) {
      return this.uhManoa;
    }
    else {
    return this.uhManoa + " " + this.hawaiiStateLib;
    }
  }

  /**
   * Returns the user parameters for the Hawaii State library.
   * @return A string of HSL arguments.
   */
  public String getHsl() {
    return this.hawaiiStateLib;
  }
  
  /**
   * Returns the user parameters for the UH Library.
   * @return A string of Uh library arguments.
   */
  public String getUh() {
    return this.uhManoa;
  }
  
  
}
